'use strict';
var usemin = require('gulp-usemin');
var uglify = require('gulp-uglify');
var htmlmin = require('gulp-htmlmin');
var cleanCss = require('gulp-clean-css');
var clean = require('gulp-clean');
var rev = require('gulp-rev');
const jshint = require('gulp-jshint');

var gulp = require('gulp');

gulp.task("clean", function() {
    return gulp.src("h5dist/");
        // .pipe(clean());
});

gulp.task('usemin', ['clean'], function() {
    return gulp.src('h5/index.html', { buffer: true })
        .pipe(usemin({
            html: [htmlmin({ collapseWhitespace: true })],
            css1: [cleanCss(), rev()],
            j1: [rev()],
            j2: [rev()],
            // j4: [rev()],
            // j5: [jshint(),uglify(),rev()],
            // cjs: [uglify()],
        }))
        .pipe(gulp.dest('h5dist/'));
});

gulp.task('copy', ['usemin'], function() {
    return gulp.src('h5/views/*.html')
        .pipe(htmlmin({ collapseWhitespace: true }))
        .pipe(gulp.dest('h5dist/views'));
});


gulp.task('default', ['copy']);
